//package com.authorization.authorizationserveronsso.security.handle;
//
//import com.alibaba.fastjson.JSON;
//import com.authorization.authorizationserveronsso.utils.DataBus;
//import com.authorization.authorizationserveronsso.utils.HttpStatus;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.Serializable;
//
//@Component
//public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable
//{
//    private static final long serialVersionUID = -8970718410437077606L;
//
//    @Override
//    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ee)
//            throws IOException{
//        // 响应认证不通过
//        int code = HttpStatus.UNAUTHORIZED;
//        //ServletUtils.renderString(response, JSON.toJSONString(DataBus.success().data(String.valueOf(code), msg)));
//        try{
//            response.setStatus(200);
//            response.setContentType("application/json");
//            response.setCharacterEncoding("utf-8");
//            response.getWriter().print(JSON.toJSONString(DataBus.success().data(String.valueOf(code), "请求访问：{}，认证失败，无法访问系统资源")));
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//}
